let common = {
  top: 1,
  bottom: 2
}

let obj = {
  age: 12,
  name: 'obj',
  border1: common,
  border2: common,
}

const deepClone = (obj, hash = new WeakMap()) => {
  if (obj === null || typeof obj !== 'object') {
    return obj;
  }
  if (hash.has(obj)) {
    return hash.get(obj);
  }
  const objCopy = new obj.constructor
  hash.set(obj, objCopy);
  Object.keys(obj).forEach(key => {
    objCopy[key] = deepClone(obj[key], hash);
  });

  return objCopy;
}

const obj2 = deepClone(obj)
console.log(obj2.padding === obj2.margin)